using System;
using CSW.Framework.UI.DevEx.UserControls;

namespace CSW.Framework.UI.DevEx.Forms
{
    /// <summary>
    /// DXBaseLookupForm.
    /// </summary>
    public partial class DXBaseLookupForm : DXBaseEditForm
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="DXBaseLookupForm"/> class.
        /// </summary>
        protected DXBaseLookupForm()
        {
            InitializeComponent();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            SetSelectedItemAndClose();
        }

        private void grid_RowDoubleClick(object sender, RowDoubleClickEventArgs e)
        {
            SetSelectedItemAndClose();
        }

        /// <summary>
        /// Sets the selected item (if any) and closes the form.
        /// </summary>
        /// <example>
        /// <![CDATA[
        /// protected override void SetSelectedItemAndClose()
        /// {
        ///     SelectedItem = m_Grid.GetSelectedObject();
        ///     if (SelectedItem != null)
        ///         Close();
        /// }
        /// 
        /// public AppUser SelectedItem
        /// {
        ///     get; private set;
        /// }
        /// ]]>
        /// </example>
        protected virtual void SetSelectedItemAndClose()
        {
            throw new NotImplementedException(string.Format("Override the 'SetSelectedItemAndClose' method in '{0}'", GetType().FullName));
        }
    }
}